//
//  RBLoginRegisterTextfield.m
//  Budejie
//
//  Created by 华杨科技 on 2017/9/29.
//  Copyright © 2017年 饶波. All rights reserved.
//

#import "RBLoginRegisterTextfield.h"

static NSString *const RBPlacehodlerColorKey = @"placeholderLabel.textColor";
@implementation RBLoginRegisterTextfield

- (void)awakeFromNib {
    [super awakeFromNib];
    
    
    // 设置光标颜色
    self.tintColor = [UIColor whiteColor];
    
    // 设置默认的占位文字颜色
    [self setValue:[UIColor grayColor] forKeyPath:RBPlacehodlerColorKey];

    // 方式一：addTarget方式
    [self addTarget:self action:@selector(editingDidBegin) forControlEvents:(UIControlEventEditingDidBegin)];
    [self addTarget:self action:@selector(editingDidEnd) forControlEvents:(UIControlEventEditingDidEnd)];
}

- (void)editingDidBegin 
{
    [self setValue:[UIColor whiteColor] forKeyPath:RBPlacehodlerColorKey];
}

- (void)editingDidEnd
{
    [self setValue:[UIColor grayColor] forKeyPath:RBPlacehodlerColorKey];
}
@end
